﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GBL.Repository.CoatOfArms;
using GBL.Repository.Resources;

namespace GBlasonLogic.Tools
{
    /// <summary>
    /// Constraint set special for the divisions
    /// as a division is a regroupment of several shapes, this information ought to be coupled with the other divisions constraint set
    /// </summary>
    public class ConstraintDivisionSet : ConstraintSet
    {
        /// <summary>
        /// Gets or sets the type of division.
        /// </summary>
        /// <value>
        /// The type of division.
        /// </value>
        public DivisionType TypeOfDivision { get; set; }

        /// <summary>
        /// Gets or sets the division position.
        /// </summary>
        /// <value>
        /// The division position.
        /// </value>
        public Points DivisionPosition { get; set; }

        public ConstraintDivisionSet Clone()
        {
            return new ConstraintDivisionSet
                {
                    CurrentGeometry = CurrentGeometry,
                    DivisionPosition = DivisionPosition,
                    TypeOfDivision = TypeOfDivision,
                    Type = Type
                };
        }

        /// <summary>
        /// Create a sub division based on the current contraint and a position
        /// </summary>
        /// <param name="parent">The parent containing the constraint. Can't be null</param>
        /// <param name="divisionPosition">The specific points where this division is in the constraint</param>
        /// <returns>a new division with the specific constraints defined</returns>
        public Division CreateSubDivision(
            ConstraintDivisionSet parent,
            Points divisionPosition)
        {
            var updatedConstraint = Clone();
            updatedConstraint.DivisionPosition = divisionPosition;
            return new Division
            {
                Geometry = DivisionManager.GetPathFromConstraints(parent, updatedConstraint),
                Type = updatedConstraint.TypeOfDivision,
                Position = divisionPosition
            };
        }
    }
}
